/**
 * 
 */
package com.easidea.tim.entity.inventory;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.commodity.Product;

/**
 * 盘点信息
 * @author Harrison
 *
 */

@Entity(name="tim_inventory_inventory")
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Cache(region="tim_inventory_inventory",usage=CacheConcurrencyStrategy.READ_WRITE)
@Undeletable(status="deleted")
public class Inventory extends BaseEntity {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1561704507084635517L;
	
	
	public static short INVENTORY_STATUS_BOOK =  1; // 盘点登记
	public static short INVENTORY_STATUS_CONFIRM = 2; // 登记完成
	public static short INVENTORY_STATUS_SAVE = 3; // 盘点调整完成（出入库）
	public static short INVENTORY_STATUS_COMPLETE = 4; // 盘点完成

	private String productName; // 品名
	private String colorCode; //色号
	private Double totalMeterNum; // 盘点登记总米数
	private Double totalPiNum; //盘点登记总匹数
	private Boolean sampleFlag; // 是否剪样
	private Date inventoryDate; // 盘点日期
	private List<InventoryItem> inventoryItemList; // 明细数据
	private Product product; //布品
	private Double totalMarginNum; // 盘点差异米数
	private Double totalMarginPiNum; // 盘点差异匹数
	private List<InventoryMarginItem> inventoryMarginList; //盘点差异列表
	private Short status; //状态
	private String flowNo; // 业务流编号
	
	/**
	 * @return the productName
	 */
	@Column(name="product_name")
	public String getProductName() {
		return productName;
	}
	/**
	 * @param productName the productName to set
	 */
	public void setProductName(String productName) {
		this.productName = productName;
	}
	/**
	 * @return the totalMeterNum
	 */
	@Column(name="total_meter_num")
	public Double getTotalMeterNum() {
		return totalMeterNum;
	}
	/**
	 * @param totalMeterNum the totalMeterNum to set
	 */
	public void setTotalMeterNum(Double totalMeterNum) {
		this.totalMeterNum = totalMeterNum;
	}
	/**
	 * @return the totalPiNum
	 */
	@Column(name="total_pi_num")
	public Double getTotalPiNum() {
		return totalPiNum;
	}
	/**
	 * @param totalPiNum the totalPiNum to set
	 */
	public void setTotalPiNum(Double totalPiNum) {
		this.totalPiNum = totalPiNum;
	}
	/**
	 * @return the sampleFlag
	 */
	@Column(name="is_sample")
	public Boolean getSampleFlag() {
		return sampleFlag;
	}
	/**
	 * @param sampleFlag the sampleFlag to set
	 */
	public void setSampleFlag(Boolean sampleFlag) {
		this.sampleFlag = sampleFlag;
	}
	/**
	 * @return the inventoryItemList
	 */
	@OneToMany(mappedBy="inventory",cascade=CascadeType.REMOVE,fetch=FetchType.LAZY)
	public List<InventoryItem> getInventoryItemList() {
		return inventoryItemList;
	}
	/**
	 * @param inventoryItemList the inventoryItemList to set
	 */
	public void setInventoryItemList(List<InventoryItem> inventoryItemList) {
		this.inventoryItemList = inventoryItemList;
	}
	/**
	 * @return the colorCode
	 */
	@Column(name="color_code")
	public String getColorCode() {
		return colorCode;
	}
	/**
	 * @param colorCode the colorCode to set
	 */
	public void setColorCode(String colorCode) {
		this.colorCode = colorCode;
	}
	/**
	 * @return the inventoryDate
	 */
	@Column(name="inventory_date")
	@Temporal(TemporalType.DATE)
	public Date getInventoryDate() {
		return inventoryDate;
	}
	/**
	 * @param inventoryDate the inventoryDate to set
	 */
	public void setInventoryDate(Date inventoryDate) {
		this.inventoryDate = inventoryDate;
	}
	/**
	 * @return the product
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="product_id")
	public Product getProduct() {
		return product;
	}
	/**
	 * @param product the product to set
	 */
	public void setProduct(Product product) {
		this.product = product;
	}
	/**
	 * @return the totalMarginNum
	 */
	@Column(name="total_margin_num")
	public Double getTotalMarginNum() {
		return totalMarginNum;
	}
	/**
	 * @param totalMarginNum the totalMarginNum to set
	 */
	public void setTotalMarginNum(Double totalMarginNum) {
		this.totalMarginNum = totalMarginNum;
	}
	/**
	 * @return the totalMarginPiNum
	 */
	@Column(name="total_margin_pi_num")
	public Double getTotalMarginPiNum() {
		return totalMarginPiNum;
	}
	/**
	 * @param totalMarginPiNum the totalMarginPiNum to set
	 */
	public void setTotalMarginPiNum(Double totalMarginPiNum) {
		this.totalMarginPiNum = totalMarginPiNum;
	}
	/**
	 * @return the inventoryMarginList
	 */
	@OneToMany(mappedBy="inventory",cascade=CascadeType.REMOVE,fetch=FetchType.LAZY)
	public List<InventoryMarginItem> getInventoryMarginList() {
		return inventoryMarginList;
	}
	/**
	 * @param inventoryMarginList the inventoryMarginList to set
	 */
	public void setInventoryMarginList(List<InventoryMarginItem> inventoryMarginList) {
		this.inventoryMarginList = inventoryMarginList;
	}
	/**
	 * @return the status
	 */
	@Column(name="status")
	public Short getStatus() {
		return status;
	}
	/**
	 * @param status the status to set
	 */
	public void setStatus(Short status) {
		this.status = status;
	}
	
	/**
	 * @return the flowNo
	 */
	@Column(name="flow_no", nullable=false)
	public String getFlowNo() {
		return flowNo;
	}
	/**
	 * @param flowNo the flowNo to set
	 */
	public void setFlowNo(String flowNo) {
		this.flowNo = flowNo;
	}
}
